﻿#include "formulabase.h"
#include "tools.h"
#include <QJsonObject>

FormulaBase::FormulaBase(QObject *parent) : QObject(parent)
{

}

FormulaBase::FormulaBase(QJsonObject obj){
    loadFromJsonObject(obj);
}

void FormulaBase::loadFromJsonObject(QJsonObject obj){
    id = obj.value("id").toInt();

    companyId = obj.value("company_id").toString();
    combineId = obj.value("combine_id").toString();
    combineCount = obj.value("combine_count").toInt();
    splitIds = obj.value("split_ids").toString();
    splitCounts = obj.value("split_counts").toString();

//    Tools::cout("id:"+QString("%1").arg(id));
//    Tools::cout("companyId:"+companyId);
//    Tools::cout("combineId:"+combineId);
//    Tools::cout("combineCount:"+QString("%1").arg(combineCount));
//    Tools::cout("splitIds:"+splitIds);
//    Tools::cout("splitCounts:"+splitCounts);
}

void FormulaBase::loadFromSqlQuery(QSqlQuery query){
    id = query.value(0).toInt();
    companyId = query.value(1).toString();
    combineId = query.value(2).toString();
    combineCount = query.value(3).toInt();
    splitIds = query.value(4).toString();
    splitCounts = query.value(5).toString();
}
